package com.kim.receiver.server.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.kim.receiver.server.entity.UserInfo;
import com.kim.receiver.server.mapper.UserInfoMapper;
import com.kim.receiver.server.service.IUserInfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * <p>
 * 用户信息表 服务实现类
 * </p>
 *
 * @author KimWu
 * @since 2020-12-29
 */
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements IUserInfoService {

    @Resource
    private UserInfoMapper userInfoMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addNoTxlcn() {
        userInfoMapper.insert(build());
        int i = 1 / 0;
    }

    @Override
    @LcnTransaction
    @Transactional(rollbackFor = Exception.class)
    public void addTxlcn() {
        userInfoMapper.insert(build());
        int i = 1 / 0;
    }

    private UserInfo build() {
        return new UserInfo(null, 123456L, "txlcnName", "M", null,
                null, null, null, null, null, null,
                false, null, null, 0);
    }
}
